/*
 * @Author: wangtao
 * @Date: 2021-01-14 16:00:34
 * @LastEditors: 汪滔
 * @LastEditTime: 2021-02-01 16:45:37
 * @Description: file content
 */
import React, {Component} from 'react';
import {TouchableOpacity, StyleSheet, View, Text, Image} from 'react-native';
import {
  px2dp,
  mainBgColorWhite,
  fontColorBlack,
  fontColorCoffee,
} from '../../../../../common/styles/index';
import {_} from '../../../../../common';

import {iconPositionCoffee} from '../../../../../image';

export default class CurrentPosition extends Component {
  render() {
    const {currentPosition,selectMapPosition} = this.props;
    if (!currentPosition.street) {
      return null
    }
    currentPosition.name = currentPosition.addressDetail
    return (
      <TouchableOpacity style={styles.currentPostionWrap} activeOpacity={0.8} onPress={()=>selectMapPosition(currentPosition)}>
        <View style={styles.currentPostionLeft}>
          <Image
            style={[styles.iconPositionImg]}
            resizeMode="contain"
            source={iconPositionCoffee}
          />
        </View>
        <View style={styles.currentPostionRight}>
          <Text style={styles.currentPostionName}>
          {currentPosition.street}
            <Text style={styles.currentPostionLabel}>(当前位置)</Text>
          </Text>
          <Text style={styles.currentPostionDesc}>
            {currentPosition.addressDetail}
          </Text>
        </View>
      </TouchableOpacity>
    );
  }
}
const styles = StyleSheet.create({
  currentPostionWrap: {
    height: px2dp(154),
    flexDirection: 'row',
    alignItems: 'center',
    backgroundColor: mainBgColorWhite,
  },
  currentPostionLeft: {
    width: px2dp(88),
    height: '100%',
    alignItems: 'center',
    justifyContent: 'center',
  },
  iconPositionImg: {
    width: px2dp(40),
    height: px2dp(40),
  },
  currentPostionRight: {
    flex: 1,
    height: '100%',
    justifyContent: 'center',
  },
  currentPostionName: {
    fontSize: px2dp(32),
    color: fontColorBlack,
    fontWeight: '600',
  },
  currentPostionLabel: {
    fontSize: px2dp(28),
    color: fontColorCoffee,
  },
});
